package com.tianqi.modules.pms.controller;

import com.nlf.calendar.Solar;
import com.nlf.calendar.SolarMonth;
import com.tianqi.common.api.CommonResult;
import com.tianqi.common.utils.TimeUtils;
import com.tianqi.modules.pms.dto.request.ArrangeDiskReqDTO;
import com.tianqi.modules.pms.dto.response.CalendarDaysDTO;
import com.tianqi.modules.pms.dto.response.CalendarNowDayDTO;
import com.tianqi.modules.pms.dto.response.EightCharAllRespDTO;
import com.tianqi.modules.pms.dto.response.EightCharPartRespDTO;
import com.tianqi.modules.pms.service.TianganDizhiService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @className: TianganDizhiController
 * @description: 天干地支控制类
 * @author: zp
 * @create: 2023-08-07 08:41
 **/
@RestController
@RequestMapping("/pms/tianganDizhi")
@Slf4j
public class TianganDizhiController {
    @Autowired
    private TianganDizhiService tianganDizhiService;
    @Autowired
    private TimeUtils timeUtils;


    @ApiOperation(value = "根据日期获取八字")
    @RequestMapping(value = "/getEightCharacters", method = RequestMethod.POST)
    public CommonResult<EightCharAllRespDTO> getEightCharacters(@RequestBody @Validated ArrangeDiskReqDTO arrangeDiskReqDTO) {

        return tianganDizhiService.getEightCharacters(arrangeDiskReqDTO);
    }

    @ApiOperation(value = "根据日期获取八字-大运部分")
    @RequestMapping(value = "/getEightCharPart", method = RequestMethod.POST)
    public CommonResult<EightCharPartRespDTO> getEightCharPart(@RequestBody @Validated ArrangeDiskReqDTO arrangeDiskReqDTO) {

        return tianganDizhiService.getEightCharPart(arrangeDiskReqDTO);
    }

    @ApiOperation(value = "初始化")
    @RequestMapping(value = "/timeChuShiHuawei", method = RequestMethod.POST)
    public void timeChuShiHuawei() {
        timeUtils.TimeConvertShengShi();
    }

    @ApiOperation(value = "根据日期获取万年历")
    @RequestMapping(value = "/getCalendarDays", method = RequestMethod.GET)
    public CommonResult<CalendarNowDayDTO> getCalendarDays(@RequestParam(value = "yearMonth", required = false) String yearMonth){
        return tianganDizhiService.getCalendarDays(yearMonth);
    }


}
